package com.lsh.service;

import com.lsh.annotation.Autowired;
import com.lsh.annotation.Component;
import com.lsh.annotation.Scope;
import com.lsh.spring.*;


@Component
@Scope("prototype")
public class UserService implements BeanNameAware, InitializingBean, UserInterface {

    //推断构造方法
    //判断是否有无参构造，有了就用无参
    //当有多个时，默认去找无参构造，没有无参会报错
    //可以在需要使用的构造方法上加@Autowired注解  直接从单例池拿出来用，没有就创建
    //先byType，再byName
    public UserService() {
    }

    public UserService(OrderService orderService) {
        this.orderService = orderService;
    }

    @Autowired
    private OrderService orderService;

    private String beanName;

    private String xxx;

    public void test(){
        System.out.println(orderService);
    }

    @Override
    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public void xxxxxx(){

    }

    @Override
    public void afterPropertiesSet() {
        // ............
        System.out.println("初始化方法");
    }
}
